<%@ page import="cn.wolfcode.domain.File" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.wolfcode.qo.PageResult" %>
<%@ page import="cn.wolfcode.qo.ProductQueryObject" %><%--
  Created by IntelliJ IDEA.
  User: 孙晓萌
  Date: 2021/8/13
  Time: 20:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    String username=(String) request.getSession().getAttribute("username");
    Long uid = (Long)request.getSession().getAttribute("uid");
    if(username!=null&&uid!=null){
        PageResult<File> pageResult = (PageResult<File>) request.getAttribute("pageResult");
        request.setAttribute("pageResult", pageResult);
    }else {
        response.sendRedirect("index.jsp");
    }
%>
<form action="/chaxunServlet" method="post">
    <h3>欢迎：${username}</h3>
    <a href="/chaxunServlet?cmd=zhuxiao">注销</a>
    <a href="/chaxunServlet?cmd=input2">添加</a>
    <table border="1" cellspacing="0" cellpadding="0" width="80%" style="text-align: center">
        <tr>
            <th>编号</th>
            <th>文件名</th>
            <th>操作</th>
        </tr>
        <c:forEach var="file" items="${pageResult.data}" varStatus="status">
            <tr class="yangshi">
               <td>${file.id}</td>
                <td>${file.filename}</td>
                <td>
                    <a href="/chaxunServlet?cmd=input&id=${file.id}">编辑</a>
                    <a href="/chaxunServlet?cmd=delete&id=${file.id}">删除</a>
                    <a href="/chaxunServlet?cmd=xiazai&filepath=${file.filepath}&filename=${file.filename}">下载文件</a>
                </td>
            </tr>
        </c:forEach>
        <tr align="center">
            <td colspan="11">
                <a href="/chaxunServlet?currenPage=1">首页</a>
                <a href="/chaxunServlet?currenPage=${pageResult.prevPage}">上一页</a>
                <a href="/chaxunServlet?currenPage=${pageResult.nextPage}">下一页</a>
                <a href="/chaxunServlet?currenPage=${pageResult.totalPage}">尾页</a>
                当前页${pageResult.currentPage} / ${pageResult.totalPage}
                一共${pageResult.totalCount}条数据
                跳转到[ <input type="number" onchange="changePage()" name="currenPage"
                            value="${pageResult.currentPage}" style="width: 60px;"> ]
                每页[
                <select name="pageSize" onchange="changePage()">
                    <option value="3" ${pageResult.pageSize == 3?'selected':''}>3</option>
                    <option value="5" ${pageResult.pageSize == 5?'selected':''}>5</option>
                    <option value="10" ${pageResult.pageSize == 10?'selected':''}>10</option>
                </select>
                ]条数据

            </td>
        </tr>
    </table>
</form>
<script type="text/javascript">
    window.onload = function () {
        var trClzs = document.getElementsByClassName("yangshi");
        for (var i = 0; i < trClzs.length; i++) {
            trClzs[i].onmouseover = function () {
                this.style.backgroundColor = "#FF7300";
            }
            trClzs[i].onmouseout = function () {
                this.style.backgroundColor = "";
            }
        }
    }

    function changePage() {
        document.forms[0].submit();
    }
</script>
</body>
</html>
